local skel = fk.CreateSkill {
  name = "emo__liqun",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["emo__liqun"] = "离群",
  [":emo__liqun"] = "锁定技，每当你受到伤害时，若你本轮未进入回合，你摸X张牌（X为伤害来源与你座位号之差，至少为1），若你下家本轮未进入回合，你与其交换座位，并防止此伤害。",
}

skel:addEffect(fk.DamageInflicted, {
  anim_type = "masochism",
   can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and target == player then
      return #player.room.logic:getEventsOfScope(GameEvent.Turn, 1, function (e) return e.data.who == player end, Player.HistoryRound) == 0
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    local n = 0
    if data.from then
      n = math.abs(player.seat - data.from.seat)
    end
    n = math.max(1, n)
    player:drawCards(n, skel.name)
    local next = player:getNextAlive(true)
    if next and next ~= player and #room.logic:getEventsOfScope(GameEvent.Turn, 1, function (e)
     return e.data.who == next end, Player.HistoryRound) == 0 then
      room:swapSeat(player, next)
      data:preventDamage()
    end
  end,
})

return skel
